package com.gitee.huxing.mybatis.core.transaction;

import org.apache.ibatis.session.TransactionIsolationLevel;
import org.apache.ibatis.transaction.Transaction;
import org.apache.ibatis.transaction.TransactionFactory;

import javax.sql.DataSource;
import java.sql.Connection;
import java.util.Properties;

/**
 * @Description: spring事务管理工程
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.mybatis.core.transaction
 * @ClassName: SpringManagedTransactionFactory
 * @Author: huxing
 * @DateTime: 2021-09-16 下午5:25
 */
public class SpringManagedTransactionFactory implements TransactionFactory {

    @Override
    public void setProperties(Properties props) {
    }

    @Override
    public Transaction newTransaction(Connection connection) {
        throw new UnsupportedOperationException("New Spring transactions require a DataSource");
    }

    @Override
    public Transaction newTransaction(DataSource dataSource, TransactionIsolationLevel transactionIsolationLevel, boolean b) {
        return new SpringManagedTransaction(dataSource);
    }
}
